import URLTitle from "../URLTitle";
import TokenAxios from "../TokenAxios";
import BaseUrl from "@/http/BaseUrl";

/** 封装商城所有的接口方法 */
const MallAPI= {
    /**
     * 查询类别树
     * @param {Object} params {id:1}
     */
    getCategoriesTree(){
        let url =URLTitle.FRONT_MALL_CATEGORIES_TREE;
        return TokenAxios.get(url)
    },
    /**
     * 根据父级查询子级列表
     */
    getCategoriesByParent(params){
        let url = URLTitle.FRONT_MALL_CATEGORIES_LIST_BY_PARENT;
        return TokenAxios.get(url, params)
    },
    /**
     * 根据ID查询商品
     */
    getGoodsByID(params){
        let url =BaseUrl.FRONT_MALL+"/goods/"+params;
        return TokenAxios.get(url)
    },
    /**
     * 查询推荐的商品列表
     */
    getGoodsByRecommend(params){
        let url = URLTitle.FRONT_MALL_GOODS_LIST_BY_RECOMMEND
        return TokenAxios.get(url,params)
    },
    /**
     * 根据类别查询商品列表
     */
    getGoodsByCategory(params){
        let url = URLTitle.FRONT_MALL_GOODS_LIST_BY_CATEGORY
        return TokenAxios.get(url,params)
    },
    /**
     * 添加收货地址
     */
    AddAddresses(params){
        let url = URLTitle.FRONT_MALL_ADDRESSES_ADD
        return TokenAxios.post(url,params)
    },
    /**
     * 删除收货地址
     */
    DeleteAddressesByID(params){
        let url =BaseUrl.FRONT_MALL+"/receiver-addresses/"+params+"/delete";
        return TokenAxios.post(url)
    },
    /**
     * 修改收货地址
     */
    UpdateAddressesByID(params){
        let url =BaseUrl.FRONT_MALL+"/receiver-addresses/"+params+"/update";
        return TokenAxios.post(url)
    },
    /**
     * 设置默认收货地址
     */
    SetDefaultAddressesByID(params){
        let url =BaseUrl.FRONT_MALL+"/receiver-addresses/"+params+"/set-default";
        return TokenAxios.post(url)
    },
    /**
     * 根据ID查询收货地址
     */
    GetAddressesByID(params){
        let url =BaseUrl.FRONT_MALL+"/receiver-addresses/"+params;
        return TokenAxios.get(url)
    },
    /**
     * 查询收货地址列表
     */
    getAddresssesList(params){
        let url = URLTitle.FRONT_MALL_ADDRESSES_LIST
        return TokenAxios.get(url,params)
    },

    /**
     * 发表商品评论
     */
    AddComments(params){
        let url = URLTitle.FRONT_MALL_COMMENTS_ADD
        return TokenAxios.post(url,params)
    },
    /**
     * 查询商品的评论列表
     */
    getCommentsList(params){
        let url = URLTitle.FRONT_MALL_COMMENTS_LIST
        return TokenAxios.get(url,params)
    },
}

export default MallAPI;
